processTS <- function (d,locus){


    d = subset(d, Locus == locus);
    d = subset(d,ID!="")
 	d$ID = droplevels(d$ID)
    IDs= levels(d$ID);
	
     out = c("ID", 
			"Presentation Level",
			"Locus",
			"Preference",
			"Familiarity",
			as.character(seq(0,max(d$Time),by=0.04)))
        
    
  	for (j in IDs){
   			ct = subset(d,ID==j)
 			ct$ID= droplevels(ct$ID)
    		ct$Emotion <- factor(ct$Emotion,levels=c			("Excited","Happy","Calm","Sad","Scared","Angry","Elsewhere","Centre"))
    
			col = c(as.character(ct$ID[1]), 
			as.character(ct$Level[1]),
			as.character(ct$Locus[1]),
			as.character(ct$Like[1]),
			as.character(ct$Know[1]),
			as.character(ct$Emotion))

			# Append to each - ID should be the same, and therefore each should have exactly the same IDs in the same order
			out = cbind(out,col);
	   		
	   		
    } 
	return(out);

}